package lib.wzh.com.libcore.framework.exception;

import lib.wzh.com.libcore.framework.enums.ResponseEnum;
import lib.wzh.com.libcore.framework.interfaces.BaseEnum;

import java.io.Serializable;

/**
 * @Author lib
 * @Date 2021/11/23 16:44
 * @ClassName BusinessException
 * @Version v1.0
 */

public class BusinessException extends RuntimeException implements Serializable {

    private final String code;

    public BusinessException() {
        super(ResponseEnum.FAIL.msg());
        this.code = ResponseEnum.FAIL.code();
    }

    public BusinessException(BaseEnum baseEnum){
        super(baseEnum.msg());
        this.code = baseEnum.code();
    }

    public BusinessException(String message) {
        super(message);
        this.code = ResponseEnum.FAIL.code();
    }

    public BusinessException(String code, String message) {
        super(message);
        this.code = code;
    }

    public String getCode() {
        return code;
    }
}
